#!/usr/bin/perl 
use DBI;
use CGI;
# use TTrakerSite;
use TTraker;

& print_header;
& initialize_dbi;

$query = CGI->new;
$num = $query->param('num');
$name = $query->param('name');
$date = $query->param('date');
$total = $query->param('total');
$fancy = $query->param('fancy_date');

# print "GETTING SUMMARY FOR $num $date<br/>";
my $daily_summary = get_daily_time_summary ($num, $date);
my @jobs = @$daily_summary; 

# for $i (0..$#jobs ) {
#  my $cli = $jobs[$i][0];
#   my $elap = $jobs[$i][1];
# }

& print_employee_summary;

db_disconnect();

##################### SUBROUTINES FOLLOW  #####################

sub print_employee_summary
{
  print <<ENDHEADER;
  <html>
  <head>
  <link rel='stylesheet' type='text/css' href='${css_ref}trak.css' />
  <script type='text/javascript' src='${js_ref}trak.js'></script>
  <title>trak_03_sup_confirm_payroll.pl</title>
  </head>
  <body>
  <h2><center>${banner}</center></h2>
  <hr/>
  <div id='box5_1'>
  <h3>Work Summary <br/> Employee: $name <br/> Date: $fancy</h3>
  <form onkeypress='return event.keyCode != 13;' autocomplete='off'  name='activity' action='${cgi_ref}trak_04_sup_update_payroll.pl' method='post'>
  <input type="hidden" name="empName" value='$name'/>
  <input type="hidden" name="empNum" value='$num'/>
  <input type="hidden" name="date" value='$date'/>
  <input type="hidden" name="total" value='$total'/>
  <input type="hidden" name="fancy_date" value='$fancy'/>
  <table>
    <tr>
      <th id="warn">Client</th>
      <th id="warn">Time</th>
    </tr>
ENDHEADER
	for $i (0..$#jobs ) {
		my $cli = $jobs[$i][0];
	  	my $elap = $jobs[$i][1];
   print <<ENDHEADER;
   <tr>
     <td><b>&nbsp&nbsp&nbsp $cli</b></td>
     <td><b>&nbsp&nbsp&nbsp $elap</b></td>
   </tr>
ENDHEADER
}
# NEED TO CREATE BUTTONS FOR THE PAGES
# <a class="button" href="trak_02_sup_detailed_info.pl"><span>Show Time Line</span></a><br/> 

print <<ENDHEADER;
	<tr>
     <td><b>&nbsp&nbsp&nbsp</b></td>
     <td><b>&nbsp&nbsp&nbsp</b></td>
   </tr>
   <tr>
     <td><b>&nbsp&nbsp&nbsp Total</b></td>
     <td><b>&nbsp&nbsp&nbsp $total</b></td>
   </tr>
 </table>
 <br/><br/>
<a class="button" href="trak_05_sup_daily_time_line.pl?num=$num&name=$name&date=$date&total=$total&fancy_date=$fancy"><span><b>Show Detailed Time Line</b></span></a><br/> 
 </form>
 </body>
 </html>
ENDHEADER
}

# &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
# <a href="${cgi_ref}trak_00_start_up.pl">Return to Log-In</a>
 
# &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
 
# <a href="trak_05_sup_daily_time_line.pl?num=$num&name=$name&date=$date&total=$total&fancy_date=$fancy" <b>Show Detailed Time Sheet</b></a><br/></br>



sub start_up
{
print <<ENDHEADER;
<html>
<head>
<link rel="stylesheet" type="text/css" href="${css_ref}trak.css" />
<script type="text/javascript" src="${js_ref}trak.js"></script>
<title>${cgi_ref}trak_00_start_up.pl</title>
</head>
<body onload="startTime()">
<h2><center>${banner}</center></h2>
<hr/>
<div id="clock"></div>
<div id="box1">
   &nbsp&nbsp&nbsp&nbsp&nbsp Employee ID: <br/><br/>
</div> 
<form id="box2" autocomplete="off" name="empID" action="${cgi_ref}trak_01_emp_log_in.pl" method="post">
   <input type="text" name=empID />&nbsp&nbsp
   <input type="submit" value="Log Into system">
   <br/><br/><br/>
</form>

</body>
</html>

ENDHEADER
}
